﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;

namespace GSPatEditor.SoundEffect
{
    class SoundEffect
    {
        private string filename;
        private Stream stream;
        private SoundPlayer sound;

        public SoundEffect(string filename)
        {
            this.filename = filename;
        }

        public void Play()
        {
            if (sound == null)
            {
                if (filename == null)
                {
                    //empty sound effect
                    return;
                }
                stream = new MemoryStream(CV3ToWavStream.ToByteArray(File.OpenRead(filename)));
                sound = new SoundPlayer(stream);
            }
            sound.Play();
        }
    }
}
